home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / LDB171.ARJ / EXAMP501.CPP < prev    next >
Text File  |  1992-05-12  |  930b  |  47 lines

  1.      // examp501.cpp - link with binder.obj
  2.      // rework of examp303.cpp
  3.  
  4.      #define ffile  "examp501.txt"
  5.  
  6.      #include <iostream.h>
  7.      #include <iomanip.h>
  8.  
  9.      #define   FType    float
  10.      #define   FBinder  fbdr
  11.      #define   FBindeR  fbdR
  12.  
  13.      #include  "fbinder.hpp"
  14.  
  15.      int fcmp(const float *f1, const float * f2)
  16.        { return (*f2 - *f1); }  // descending order
  17.  
  18.      main()    // count to five
  19.      {
  20.        fbdR fB = new fbdr (BDR_DNEW | BDR_DDELETE
  21.           | BDR_DSTORE,5);
  22.  
  23.        if (!fB)  return 1;
  24.  
  25.        float f = 1.0;
  26.  
  27.        while (fB->insNew(&f))  f++;
  28.  
  29.        fB->setComP ((BDRcomP) fcmp);
  30.        Binder::RegisterComP ((BDRcomP) fcmp);
  31.  
  32.        fB->save(ffile);
  33.  
  34.        delete fB;
  35.  
  36.        fbdr fb(ffile);
  37.  
  38.        fb.sort();
  39.  
  40.        fb.setFlags(BDR_DASSIGN);
  41.  
  42.        while (fb.prevAsg(&f))
  43.             cout << f << endl;
  44.  
  45.        return 0;
  46.      }
  47.